﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using IDAL.A;
using Model.A;

namespace DAL.A
{
    public class AppearanceCheck:BaseRepository_DT<AppearanceCheckInfo>,IAppearanceCheck 
    {
        #region 静态变量定义
        private const string PARM_APPEARANCECHECK_PACKAGEPRODUCTSN = "@PackageProductSN";
        private const string PARM_APPEARANCECHECK_USERID = "@UserID";
        private const string PARM_APPEARANCECHECK_FAILURENAME = "@FailureName";
        #endregion

        #region 数据检索部分
        public IList<AppearanceCheckInfo> LoadEntities()
        {
            return null;
        }

        public AppearanceCheckInfo LoadEntity<T1>(T1 sn)
        {
            return null;
        }

        public IList<AppearanceCheckInfo> AppearanceCheck_GetbySN(string sn)
        {
            SqlParameter parm = GetParameter();
            parm.Value = sn;
            return ExcuteSqlToGetEntities("AppearanceCheck_selectbySN", parm);
        }

        public IList<AppearanceCheckInfo> AppearanceCheck_GetbyDT(DateTime dt1, DateTime dt2)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = dt1;
            parms[1].Value = dt2;
            return ExcuteSqlToGetEntities("AppearanceCheck_selectbyDT", parms);
        }
        #endregion

        #region 重写基类方法
        public override AppearanceCheckInfo GetEntityRecord(SqlDataReader rdr)
        {
            AppearanceCheckInfo entity = new AppearanceCheckInfo(rdr.GetValue(0).ToString(), rdr.GetDateTime(1), rdr.GetValue(2).ToString()
                , rdr.GetValue(3).ToString());
            return entity;
        }

        public override AppearanceCheckInfo GetEntityRecord()
        {
            AppearanceCheckInfo entity = new AppearanceCheckInfo();
            return entity;
        }

        public override string GetInsertsp()
        {
            return "AppearanceCheck_Insert";
        }

        public override SqlParameter GetParameter()
        {
            return new SqlParameter(PARM_APPEARANCECHECK_PACKAGEPRODUCTSN, SqlDbType.NVarChar, 50);
        }

        public override SqlParameter[] GetParameters()
        {
            return new SqlParameter[]
            {
                new SqlParameter(PARM_APPEARANCECHECK_PACKAGEPRODUCTSN,SqlDbType.NVarChar,50),
                new SqlParameter(PARM_APPEARANCECHECK_USERID,SqlDbType.NVarChar,10),
                new SqlParameter(PARM_APPEARANCECHECK_FAILURENAME,SqlDbType.NVarChar,50)
            };
        }

        public override void SetParameters(AppearanceCheckInfo Entity, params SqlParameter[] Parms)
        {
            Parms[0].Value = Entity.PackageProductSN;
            Parms[1].Value = Entity.UserID;
            Parms[2].Value = Entity.FailureName;
        }
        #endregion
    }
}
